import 'package:animal/network/api.dart';
import 'package:animal/ui/goods/NWApi.dart';
import 'package:animal/ui/goods/page/goods_info_page.dart';
import 'package:animal/ui/goods/page/goods_search_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class ShopSmallController extends GetxController{
  //滚动controller
  ScrollController? scrollController;
  ScrollController? nestedScrollController;

  var appBarColor = Colors.transparent.obs;

  var top = 0.0.obs;

  //广告banner数据

  @override
  void onInit() {
    super.onInit();
    scrollController = ScrollController();
    nestedScrollController = ScrollController();
    scroll();
    goodsBanner();
  }

  ///滚动事件监听
  void scroll(){
    nestedScrollController!.addListener(() {
      if(nestedScrollController!.offset>150){
        appBarColor.value = const Color(0XFFFFC3B3);
      }else{
        appBarColor.value = Colors.transparent;
      }
    });
  }

  ///前往商品详情
  void gotoShopInfo(){
    Get.to(GoodsInfoPage());
  }

  ///前往商品详情
  void gotoShopSearch(){
    Get.to(GoodsSearchPage());
  }

  ///获取首页广告
  void goodsBanner(){
    HttpManager().get(NWApi.goodsGetIndexList,queryParameters: {}).listen((value) {
    },onError: (err){});
  }
}